package com.syygl.test.study.leetCode;

public class Climb {
    private int step;
    public int total;
    public Climb(int step) {
        this.step = step;
    }

    public void climb(int left){
        if(left<=step){
            total+=2^(left-1);  //（这里写错了，应该是2^(left-1)）
        }else{
            for(int i=1;i<=step;i++){
                climb(left-i);
                //total++;  脑子抽了
            }
        }
    }
    public static void main(String[] args){
        Climb c=new Climb(2);
        c.climb(6);
        System.out.println(c.total);
    }
}

class Solution{

    public static void main(String[] args) {
        System.out.println(waysToStep(6, 2));
    }


    //台阶问题
    public static int waysToStep(int n, int m) {
        int[] dp = new int[n];
        for (int i = 1; i <= m; i++) {
            if (n == i) return (int)Math.pow(2,i-1);
            dp[i-1] = (int)Math.pow(2,i-1);
        }
        for (int i=m;i<n;i++) {
            for (int j = 1; j <= m; j++) {
                dp[i] = dp[i] + dp[i - j];
            }
        }
        return dp[n - 1];
    }

}
